import { UserApi } from "@/enums/apiEnum";
import { defHttp } from "@/utils/http/axios";
import qs from "qs";
import { GetUserInfoModel, SaveUserInfoModel } from "./model/userModel";
import { Recordable } from "/#/global";

export function getUserInfo() {
  return defHttp.get<GetUserInfoModel>({
    url: UserApi.GetUserInfo,
  });
}

export function getUserListByPage(params:Recordable) {
  return defHttp.get<GetUserInfoModel[]>({
    url: UserApi.GetUserListByPage,
    params 
  });
}

export function saveOrUpdateUser(user: SaveUserInfoModel) {
  return defHttp.post({ url: UserApi.RestUserApi, data: user });
}

export function deleteUserById(id: number | string) {
  return defHttp.delete({
    url: UserApi.RestUserApi,
    params: '?'+qs.stringify({ id: id }),
  });
}
